package storm.online.common;

import org.json.JSONException;
import org.json.JSONObject;

public class LoginInfo {
	private String gameId;
	private Long areaId;
	private Long groupId;
	private String ptId;
	private Long timestamp;
	private int action; //暂时设定为1为上限，2为下线
	
	public String getGameId() {
		return gameId;
	}
	
	public void setGameId(String gameId) {
		this.gameId = gameId;
	}
	
	public Long getAreaId() {
		return areaId;
	}
	
	public void setAreaId(Long areaId) {
		this.areaId = areaId;
	}
	
	public Long getGroupId() {
		return groupId;
	}
	
	public void setGroupId(Long groupId) {
		this.groupId = groupId;
	}
	
	public String getPtId() {
		return ptId;
	}
	
	public void setPtId(String ptId) {
		this.ptId = ptId;
	}
	
	public Long getTimeStamp() {
		return timestamp;
	}
	
	public void setTimeStamp(Long timeStamp) {
		this.timestamp = timeStamp;
	}
	
	public int getAction() {
		return action;
	}
	
	public void setAction(int action) {
		this.action = action;
	}
	
	public int parseJson(String jsonStr){
		try {
			JSONObject jsonObj = new JSONObject(jsonStr);
			this.gameId = jsonObj.getString("game_id");
			this.areaId = jsonObj.getLong("area_id");
//			this.groupId = jsonObj.getLong("group_id");
			this.action = jsonObj.getInt("action");
			this.ptId = jsonObj.getString("pt_id");
			this.timestamp = jsonObj.getLong("timestamp");
		} catch (JSONException e){
			e.printStackTrace();
			return -1;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return -1;
		}
		
		return 0;
	}
}
